package com.yonyou.brigade.ybz.controller;

import com.yonyou.brigade.ybz.service.ICnvOutentitydefService;
import com.yonyou.brigade.ybz.service.ICnvOutpropertydefService;
import com.yonyou.brigade.ybz.service.ICnvRegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 向转换平台对数据建模即实体之间的关系
 *
 * @Auther: kfw
 * @Date: 2018/8/21 10:37
 */
@RestController
@RequestMapping("/ybz/def")
public class CnvEntityAndPropertyDefController {
    @Autowired
    @Qualifier("cnvRegisterServiceImpl")
    private ICnvRegisterService cnvRegisterService;


    /**
     * 数据建模注册entityDef,单表体注册可以只注册entityDef
     *
     * @Auther: kfw
     * @param null
     * @Return: String 构建结果
     * @Date: 2018/8/21 10:38
     */
    @RequestMapping("/entity")
    public String entityDef() {
        String userId = "5dbb8df8-0956-4cd1-9da3-43b180069f0f";
        String tenantId = "zrez2bx9";
        boolean result = cnvRegisterService.registerOutEntityDef(userId, tenantId);
        return result ? "外部数据建模成功！" : "外部数据建模失败！";
    }

    /**
     * 数据建模注册propertyDef，多表体注册需要注册entityDef用以标识单据并注册propertyDef关联到entityDef下
     *
     * @Auther: kfw
     * @param null
     * @Return: String 构建结果
     * @Date: 2018/8/21 10:38
     */
    @RequestMapping("/property")
    public String propertyDef() {
        String userId = "5dbb8df8-0956-4cd1-9da3-43b180069f0f";
        String tenantId = "zrez2bx9";
        boolean result = cnvRegisterService.registerOutPropertyDef(userId, tenantId);
        return result ? "外部数据建模成功！" : "外部数据建模失败！";
    }
}

